package org.example.springboot3.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.example.springboot3.domain.Users;
import org.example.springboot3.service.UsersService;
import org.example.springboot3.mapper.UsersMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author xu264
* @description 针对表【users】的数据库操作Service实现
* @createDate 2025-05-25 14:24:50
*/
@Service
public class UsersServiceImpl extends ServiceImpl<UsersMapper, Users>
    implements UsersService{
    @Resource
    private UsersMapper usersMapper; // 注入Mapper接口

    public List<Users> getUserList() {
        return usersMapper.getUserList();
    }

    public  Users getUserInfo(String id){
        return usersMapper.getUserInfo(id);
    }

    public int updateName(String id,String name){
        return usersMapper.updateName(id,name);
    }

    public int updatePhone(String id,String phone){
        return usersMapper.updatePhone(id,phone);
    }

    public int updateImg(String id,String img){
        return usersMapper.updateImg(id,img);
    }

    public int updatePwd(String id,String newPwd,String oldPwd){
        if(usersMapper.getPwd(id).equals(oldPwd))
            return usersMapper.updatePwd(id,newPwd);
        else return 0;
    }
}




